// import {getComponentList} from "@/api/dict";

import {getDict} from "@/api/common";

export const operateList = [
  {
    name: $i18n.t('common.add'),
    type: 'primary',
    icon: 'el-icon-circle-plus-outline',
    handleName: 'add', //点击时返回的标识
  }
]
export const rowConfig = [
  {
    name: '编辑',
    type: 'primary',
    class: 'row-btn-primary',
    handleName: 'edit', //点击时返回的标识
  },

  {
    name: '删除',
    type: 'danger',
    class: 'row-btn-danger',
    handleName: 'delete', //点击时返回的标识
  }
]
export const subRowConfig = [
  {
    name: '编辑',
    type: 'primary',
    class: 'row-btn-primary',
    handleName: 'editSub', //点击时返回的标识
  },

  {
    name: '删除',
    type: 'danger',
    class: 'row-btn-danger',
    handleName: 'deleteSub', //点击时返回的标识
  }
]
export const sub2RowConfig = [
  {
    name: '编辑',
    type: 'primary',
    class: 'row-btn-primary',
    handleName: 'editSub2', //点击时返回的标识
  },
  {
    name: '删除',
    type: 'danger',
    class: 'row-btn-danger',
    handleName: 'deleteSub2', //点击时返回的标识
  },
]
// 主表查询条件
export const formConfig = {
  inline: true,
  formDesc: {
    materialType: {
      type: "select",
      label: '类型',
      prop: {
        text: "description",
        value: "value"
      },
      // Promise 对象
      options: async (data) => {
        const list = await getDict("tm_material_base")
        return list.data.result
      }
    },
    materialCode: {
      type: "input",
      label: '物料编号',
    },
    materialName: {
      type: "input",
      label: '物料名称',
    },
  }
}
export const formDescDialog = {
  span: 24,
  formDesc: {
    materialType: {
      layout: 24,
      type: "select",
      label: '类型',
      prop: {
        text: "description",
        value: "value"
      },
      // Promise 对象
      options: async (data) => {
        const list = await getDict("tm_material_base")
        return list.data.result
      }
    },
    materialCode: {
      layout: 24,
      type: "input",
      label: '物料编号',
    },
    materialName: {
      layout: 24,
      type: "input",
      label: '物料名称',
    },
    materialUnit: {
      layout: 24,
      type: "select",
      label: '物料单位',
      prop: {
        text: "description",
        value: "value"
      },
      // Promise 对象
      options: async (data) => {
        const list = await getDict("material_unit")
        return list.data.result
      }
    },
    materialSafetyStock: {
      layout: 24,
      type: "number",
      label: '安全库存',
    },
  }
}
export const formConfigDialog = {
  span: 24,
  formDesc: {
    systemFlag: {
      type: 'select',
      label: $i18n.t('dict.systemFlag'),
      layout: 24,
      required: true,
      options: (data) => {
        return [
          {
            text: $i18n.t('common.yes'),
            value: '1'
          },
          {
            text: $i18n.t('common.no'),
            value: '0'
          }
        ]
      }
    }
  }
}
export const formDescDialogSub = {
  span: 24,
  formDesc: {
    materialCode: {
      layout: 24,
      type: "input",
      label: '物料编号',
      disabled: true,
    },
    brand: {
      layout: 24,
      type: "input",
      label: '品牌名称',
    },
  }
}
export const formDescDialogTwo = {
  span: 24,
  formDesc: {
    materialCode: {
      layout: 24,
      type: "input",
      label: '物料编号',
      required: true,
      disabled: true,
    },
    unit: {
      layout: 24,
      type: "input",
      required: true,
      label: '规格',
    },
    packUnit: {
      layout: 24,
      type: "select",
      required: true,
      label: '订货单位',
      prop: {
        text: "description",
        value: "value"
      },
      // Promise 对象
      options: async (data) => {
        const list = await getDict("material_pack_unit")
        return list.data.result
      },
      on: {
        change: (val) => {
          if (val === '无') {
            self.packUnitChange(val);
          }
        },
      },
    },
    packCapacity: {
      layout: 24,
      required: true,
      type: "number",
      label: '包装容量',
      disabled: (data) => {
        return data.packUnit==='无' ?  true : false;
      },
    },
    countType: {
      layout: 24,
      type: "select",
      required: true,
      label: "领用单位",
      prop: {
        value: "value",
        text: "text",
      },
      disabled: (data) => {
        return data.packUnit==='无' ?  true : false;
      },
      options: [
        {
          value: "1",
          text: "同物料基础单位"
        },
        {
          value: "2",
          text: "同订货单位"
        },
      ],
    },
  }
}
